package com.lvmama.service.rhino.supperfreetravel.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lvmama.common.exception.GlobalException;
import com.lvmama.dao.rhino.superfreetravel.SuperfreetravelDao;
import com.lvmama.pojo.entity.rhino.superfreetravel.PageView;
import com.lvmama.pojo.entity.rhino.superfreetravel.PageViewVo;
import com.lvmama.pojo.entity.rhino.superfreetravel.SearchListVo;
import com.lvmama.pojo.entity.rhino.superfreetravel.SuperfreeFlowstatistic;
import com.lvmama.service.rhino.supperfreetravel.SuperfreetravelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("SuperfreetravelService")
@Slf4j
public class SuperfreetravelServiceImpl implements SuperfreetravelService {


    @Autowired
    private SuperfreetravelDao dao;

    /**
     * 根据条件查询页面元素的流量
     * @param searchListVo
     * @return
     * @throws GlobalException
     */
    @Override
    public PageInfo<SuperfreeFlowstatistic> searchList(SearchListVo searchListVo){
        log.info(" SuperfreetravelService searchList start");
        PageInfo<SuperfreeFlowstatistic> result = null;
        try {
            PageHelper.startPage(searchListVo.getCurrentPage(), searchListVo.getPageSize());
            result = new PageInfo<>(dao.searchList(searchListVo));
        }catch (Exception e){
            log.error("SuperfreetravelService searchList error:",e.getMessage(),e);
        }
        log.info(" SuperfreetravelService searchList end");
        return result;
    }

    /**
     * 根据条件查询页面访问情况
     * @param pageViewVo
     * @return
     * @throws GlobalException
     */
    @Override
    public PageInfo<PageView> getPageViewList(PageViewVo pageViewVo){
        log.info(" SuperfreetravelService getPageViewList start");
        PageInfo<PageView> result = null;
        try {
            PageHelper.startPage(pageViewVo.getCurrentPage(), pageViewVo.getPageSize());
            result = new PageInfo<>(dao.getPageViewList(pageViewVo));
        }catch (Exception e){
            log.error("SuperfreetravelService getPageViewList error:",e.getMessage(),e);
        }
        log.info(" SuperfreetravelService getPageViewList end");
        return result;
    }
}
